import becker.robots.*;
public class superRobot extends Robot{

	public superRobot(City aCity, int aStreet, int anAvenue,
			Direction aDirection) {
		super(aCity, aStreet, anAvenue, aDirection);
	}

	public void turnRight(){
		turnLeft();
		turnLeft();
		turnLeft();
	}

	public void move(int i){
		for (int x = 0; x < i; x++){
			move();
		}
	}

	public void turnLeft(int i){
		for (int x =  0; x < i; x++){
			turnLeft();
		}
	}

	public void changeDir(Direction dir){
		while (super.getDirection()!= dir) {
			super.turnLeft();
		}
	}

	public void checkPossible(int[] possible){
		changeDir(Direction.NORTH);
		if (frontIsClear()) {
			possible[0] = 1;
		} else {
			possible[0] = 0;
		}
		changeDir(Direction.WEST);
		if (frontIsClear()) {
			possible[3] = 1;
		} else {
			possible[3] = 0;
		}
		changeDir(Direction.SOUTH);
		if (frontIsClear()) {
			possible[2] = 1;
		} else {
			possible[2] = 0;
		}
		changeDir(Direction.EAST);
		if (frontIsClear()) {
			possible[1] = 1;
		} else {
			possible[1] = 0;
		}
	}

	public int returnPossible(boolean[][] a) {
		int x = 0;
		changeDir(Direction.NORTH);
		if (getStreet() != 0 && getAvenue() != 0){
			if (frontIsClear() && (a[getStreet()+1][getAvenue()])) {
				x++;
			}
			changeDir(Direction.WEST);
			if (frontIsClear() && (a[getStreet()][getAvenue()-1])) {
				x++;
			}
			changeDir(Direction.SOUTH);
			if (frontIsClear() && (a[getStreet()-1][getAvenue()])) {
				x++;
			}
			changeDir(Direction.EAST);
			if (frontIsClear() && (a[getStreet()][getAvenue()+1])) {
				x++;
			}
		} else if (getStreet() == 0) {
			if (frontIsClear() && (a[getStreet()+1][getAvenue()])) {
				x++;
			}
			changeDir(Direction.WEST);
			if (frontIsClear() && (a[getStreet()][getAvenue()-1])) {
				x++;
			}
			changeDir(Direction.SOUTH);
			if (frontIsClear() && (a[getStreet()][getAvenue()])) {
				x++;
			}
			changeDir(Direction.EAST);
			if (frontIsClear() && (a[getStreet()][getAvenue()+1])) {
				x++;
			}
		} else if (getAvenue() == 0){
			if (frontIsClear() && (a[getStreet()+1][getAvenue()])) {
				x++;
			}
			changeDir(Direction.WEST);
			if (frontIsClear() && (a[getStreet()][getAvenue()])) {
				x++;
			}
			changeDir(Direction.SOUTH);
			if (frontIsClear() && (a[getStreet()][getAvenue()])) {
				x++;
			}
			changeDir(Direction.EAST);
			if (frontIsClear() && (a[getStreet()][getAvenue()+1])) {
				x++;
			}
		}
		return x;
	}
	public void test() {
		
	}
}
